add git config debugging
authorJoey Hess <joeyh@joeyh.name>
Mon, 15 May 2023 19:35:29 +0000 (15:35 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 15 May 2023 19:35:29 +0000 (15:35 -0400)
(and process cwd debugging)

Sponsored-by: Dartmouth College's Datalad project
Git/Config.hs
Utility/Process.hs
doc/bugs/need_more_debug_for_failing_to_get_uuid_or_key_.mdwn
doc/bugs/need_more_debug_for_failing_to_get_uuid_or_key_/comment_1_6c3efd1922015a20daf93bea54fc6431._comment [new file with mode: 0644]

index 7e12a568e0bea6438ea75c35892b957fb0474935..c76794bf1d332f0e31f8594564af371813162edc 100644 (file)
@@ -104,19 +104,23 @@ global = do
 hRead :: Repo -> ConfigStyle -> Handle -> IO Repo
 hRead repo st h = do
        val <- S.hGetContents h
-       store val st repo
+       let c = parse val st
+       debug (DebugSource "Git.Config") $ "git config read: " ++
+               show (map (\(k, v) -> (show k, map show v)) (M.toList c))
+       storeParsed c repo
 
 {- Stores a git config into a Repo, returning the new version of the Repo.
  - The git config may be multiple lines, or a single line.
  - Config settings can be updated incrementally.
  -}
 store :: S.ByteString -> ConfigStyle -> Repo -> IO Repo
-store s st repo = do
-       let c = parse s st
-       updateLocation $ repo
-               { config = (M.map Prelude.head c) `M.union` config repo
-               , fullconfig = M.unionWith (++) c (fullconfig repo)
-               }
+store s st = storeParsed (parse s st)
+
+storeParsed :: M.Map ConfigKey [ConfigValue] -> Repo -> IO Repo
+storeParsed c repo = updateLocation $ repo
+       { config = (M.map Prelude.head c) `M.union` config repo
+       , fullconfig = M.unionWith (++) c (fullconfig repo)
+       }
 
 {- Stores a single config setting in a Repo, returning the new version of
  - the Repo. Config settings can be updated incrementally. -}
index e768c13367d4e198ea74226e2044ee11c7f0a097..07f035d3426d1b633ac59c990a4ec9b45269199f 100644 (file)
@@ -189,11 +189,13 @@ withCreateProcess p action = bracket (createProcess p) cleanupProcess
 debugProcess :: CreateProcess -> ProcessHandle -> IO ()
 debugProcess p h = do
        pid <- getPid h
-       debug "Utility.Process" $ unwords
+       debug "Utility.Process" $ unwords $
                [ describePid pid
                , action ++ ":"
                , showCmd p
-               ]
+               ] ++ case cwd p of
+                       Nothing -> []
+                       Just c -> ["in", show c]
   where
        action
                | piped (std_in p) && piped (std_out p) = "chat"
index ad785991e0d6b0dc2ef37d6a902eb6695f7f93cc..9ba54986317eea68d1a3215b8668224d062de685 100644 (file)
@@ -36,3 +36,10 @@ originally in some older 8.2022  but now in 10.20230407
 
 [[!meta author=yoh]]
 [[!tag projects/datalad]]
+
+> Hard to know when there is *enough* debugging, but with what I've added,
+> I can't think of any more I could add that would help with a problem of
+> this kind. Unless of course git-annex has a deep dark bug where it reads
+> an annex.uuid from git config, but then somehow misplaces it. But I can't
+> imagine such a bug so it's hard to add debugging for it. So, I suppose
+> this is [[done]] --[[Joey]]
diff --git a/doc/bugs/need_more_debug_for_failing_to_get_uuid_or_key_/comment_1_6c3efd1922015a20daf93bea54fc6431._comment b/doc/bugs/need_more_debug_for_failing_to_get_uuid_or_key_/comment_1_6c3efd1922015a20daf93bea54fc6431._comment
new file mode 100644 (file)
index 0000000..9c4abc9
--- /dev/null
@@ -0,0 +1,24 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2023-05-15T17:43:21Z"
+ content="""
+Something that prevents `git config` from working, or prevents it from
+listing an annex.uuid for the remote, seems like the overridingly likely
+reason for their problem. (You were asking the right questions 
+[here](https://github.com/datalad/datalad/issues/7371#issuecomment-1545975295)
+and I don't think they really answered them, unless it happened in your office
+hours.)
+
+I've made --debug include the output of `git config --list`,
+which allows seeing if a problem prevents git from reading the config of
+the remote.
+
+I also made the debug output tell what directory it's running a command in
+when it's not the pwd.
+
+So, for example:
+
+       [2023-05-15 15:16:01.414302245] (Utility.Process) process [59665] read: git ["config","--null","--list"] in "/home/joey/tmp/a"
+       [2023-05-15 15:16:01.419396816] (Git.Config) git config read: [("",[]),("annex.uuid",["9553f51c-87ad-4321-86fb-de4aa630e997"]) [...]
+"""]]